package com.artifact.mit.mypoint.service.util;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;

import com.artifact.mit.mypoint.service.http.URIResources;

import android.util.AndroidRuntimeException;

public class FormatHelper {

	public static String formatDate(String date) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
		try {
			return dateFormat.format(dateFormat.parse(date));
		} catch (ParseException e) {			
			throw new AndroidRuntimeException(e);
		}		
	}
	
	public static String formatNumber(String number) {
		DecimalFormat decimalFormat = new DecimalFormat("#.###");
		return decimalFormat.format(Double.valueOf(number));
	}
	 
	public static String appendImageUrl(String url) {		
		return URIResources.MAIN_URL.concat(url.replace("~", "").replace(" ", "%20"));
	}
} 
